package me.jiatao.dagger2;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;

import java.util.Date;
import java.util.HashMap;

import javax.inject.Inject;
import javax.inject.Named;

import me.jiatao.dagger2.component.DaggerMainActivityComponent;
import me.jiatao.dagger2.component.MainActivityComponent;
import me.jiatao.dagger2.model.Address;
import me.jiatao.dagger2.model.Student;
import me.jiatao.dagger2.module.MainActivityArgsModule;

public class SubActivity extends AppCompatActivity {

    @Inject
    Student student;

    @Inject
    Date date;

    @Inject
    HashMap<String, String> stringHashMap;


    MainActivityComponent mainActivityComponent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);


        Address address = new Address();
        address.setCity("Jiangsu");
        address.setStreet("LuJia");

        mainActivityComponent = DaggerMainActivityComponent
                .builder()
                .mainActivityArgsModule(new MainActivityArgsModule(address))
                .build();
        mainActivityComponent
                .subComponent()
                .build()
                .inject(this);
    }

    public void getValue(View view) {

        Log.i("111111", mainActivityComponent.student().toString());

        Log.i("111111", student.toString());
        Log.i("222222", date.toString());
        Log.i("333333", stringHashMap.toString());
    }
}
